package com.ndp.fb.rdb.db.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.ndp.fb.rdb.api.AppInfoRdbService;
import com.ndp.fb.rdb.db.DaoTemplate;
import com.ndp.fb.rdb.db.impl.mapper.DefaultRowMapper;
import com.ndp.fb.rdb.model.AppInfo;
import com.ndp.fb.rdb.model.TLog;

import java.util.List;

/**
 * Created by infi on 2014/10/27.
 */
@Service
public class AppInfoRdbServiceImpl extends DaoTemplate implements AppInfoRdbService {

    @Override
    public AppInfo getAppInfo() {
        String sql = "select * from app_info";
        List<AppInfo> appInfoList = getJdbcTemplate().query(sql, DefaultRowMapper.autoRowMapper(AppInfo.class));
        if (appInfoList != null && appInfoList.size() > 0) {
            return appInfoList.get(0);
        } else {
            return null;
        }
    }

    @Override
    public void insertLog(TLog log) {
        saveResultId(log);
    }
}
